import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { Language } from "../../../../extend/language/Language";
import { PetIslandFightMemberListPanel } from "./PetIslandFightMemberListPanel";
import { Game } from "../../Game";
import { DisplayUtil } from "../../../common/DisplayUtil";
import { SRobIslandFightingDetail } from "../../../../Message/Game/SRobIslandFightingDetail";
import { EntityUtil } from "../../scene/layer/utils/EntityUtil";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { ObjCreate } from "../common/ObjCreate";
import { PetIslandFightObserveVo } from "./vo/PetIslandFightObserveVo";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { ResFileConst } from "../../resource/ResFileConst";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { GBitmap } from "../../../../com/mui/controls/GBitmap";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
import { ProgressBase } from "../player/ProgressBase";
import { GImageBitmap } from "../../../../com/mui/controls/GImageBitmap";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
type int = number;
//class PetIslandFightPanel
    
    export  class PetIslandFightPanel extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            setSize(836, 549);
            titleHeight = 26;
            title = Language.getString(28100);
            return;
        }

        /* internal  */onAttackMemberLinkHandler(arg1: Object /* flash.events.TextEvent */): void
        {
            if (!this._data) 
            {
                return;
            }
            if (!this._attackMemberList) 
            {
                this._attackMemberList = new PetIslandFightMemberListPanel(Language.getString(28168));
                this._attackMemberList.x = 35;
                this._attackMemberList.y = 135;
            }
            if (!this._attackMemberList.parent) 
            {
                this._listSp.addChild(this._attackMemberList);
            }
            this._attackMemberList.data = this._data.attackPlayers;
            return;
        }

        /* internal  */onDefendMemberLinkHandler(arg1: Object /* flash.events.TextEvent */): void
        {
            if (!this._data) 
            {
                return;
            }
            if (!this._defendMemberList) 
            {
                this._defendMemberList = new PetIslandFightMemberListPanel(Language.getString(28169));
                this._defendMemberList.x = 620;
                this._defendMemberList.y = 135;
            }
            if (!this._defendMemberList.parent) 
            {
                this._listSp.addChild(this._defendMemberList);
            }
            this._defendMemberList.data = this._data.defensePlayers;
            return;
        }

        /* internal  */clean(): void
        {
            Game.petIslandFight.petLayer.removeAllChildren();
            DisplayUtil.removeMe(this._attackMemberList);
            DisplayUtil.removeMe(this._defendMemberList);
            return;
        }

        public updataLife(arg1: int, arg2: int): void
        {
            if (this._data) 
            {
                this._attackLifeBar.setValue2(arg1, this._data.attackTotalLife);
                this._defendLifeBar.setValue(arg2, this._data.defenseTotaLife);
            }
            return;
        }

        public set data(arg1: SRobIslandFightingDetail)
        {
            this._data = arg1;
            this._bg.imgUrl = "PetIslandFightBg_" + this._data.island;
            this._attackName.text = this._data.attackGuildName != "" ? "[" + EntityUtil.getProxyName(arg1.attackGuildId) + "]" + this._data.attackGuildName : Language.getString(28225);
            this._defendName.text = this._data.defenseGuildName != "" ? "[" + EntityUtil.getProxyName(arg1.defenseGuildId) + "]" + this._data.defenseGuildName : Language.getString(28225);
            return;
        }

        /* internal  */onResCompl(): void
        {
            this._attackBg.bitmapData = GlobalClass.getBitmapData(ImagesConst.PetIslandFightAttack);
            this._defendBg.bitmapData = GlobalClass.getBitmapData(ImagesConst.PetIslandFightDefend);
            ObjCreate.createGBitmap(ImagesConst.PetIslandFightVS, 393, 65, this);
            return;
        }

        protected /* override */ closeBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=null;
            super.closeBtnClickHandler(arg1);
            if (this._data) 
            {
                loc1 = new PetIslandFightObserveVo();
                loc1.isObserve = false;
                loc1.placeId = this._data.placeId;
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetIslandFightObserve, loc1));
            }
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            var loc1=new GTextFormat(FontUtil.songtiName, 12, 11661311, null, null, null, null, null, flash.text.TextFormatAlign.CENTER);
            this._bg = ObjCreate.createGImageBitmap(ImagesConst.PetIslandFightBg_1, 18, 38, this);
            this._defendBg = ObjCreate.createGBitmap("", 568, 23, this);
            this._defendName = ObjCreate.createGTextField("攻击", 593, 54, 140, 20, this, loc1);
            this._defendMember = ObjCreate.createGTextField(Language.getString(28167), 643, 78, 140, 20, this, null, true);
            this._defendMember.addEventListener(flash.events.TextEvent.LINK, this.onDefendMemberLinkHandler);
            this._defendLifeBar = ObjCreate.createProgressBar(412, 50, 175, 20, this, "Shengmingtiao");
            this._defendLifeBar.setWidth(175);
            this._attackBg = ObjCreate.createGBitmap("", 15, 23, this);
            this._attackName = ObjCreate.createGTextField("防守", 96, 54, 140, 20, this, loc1);
            this._attackMember = ObjCreate.createGTextField(Language.getString(28167), 129, 78, 140, 20, this, null, true);
            this._attackMember.addEventListener(flash.events.TextEvent.LINK, this.onAttackMemberLinkHandler);
            this._attackLifeBar = ObjCreate.createProgressBar(240, 50, 175, 20, this);
            this._attackLifeBar.setWidth(175);
            this._fightPic = ObjCreate.createGLoadedButton("FightingIcon", 405, 49, 19, 18, this);
            this._fightPic.mouseEnabled = false;
            this._hideBattleBtn = ObjCreate.createGLoadedButton(ResFileConst.PetCpnHide, 357, 490, 121, 40, this);
            this._hideBattleBtn.addEventListener(flash.events.MouseEvent.CLICK, this.closeBtnClickHandler);
            Game.petIslandFight.addToStage(this);
            Game.petIslandFight.x = 114;
            Game.petIslandFight.y = 42;
            this._listSp = new Object /* flash.display.Sprite */();
            this.addChild(this._listSp);
            LoaderHelp.addResCallBack(ResFileConst.PetIslandFight, this.onResCompl);
            return;
        }

        public /* override */ hide(): void
        {
            super.hide();
            this.clean();
            return;
        }

        /* internal */ /* var */_attackBg: GBitmap;

        /* internal */ /* var */_attackName: GTextFiled;

        /* internal */ /* var */_attackMember: GTextFiled;

        /* internal */ /* var */_attackMemberList: PetIslandFightMemberListPanel;

        /* internal */ /* var */_attackLifeBar: ProgressBase;

        /* internal */ /* var */_defendBg: GBitmap;

        /* internal */ /* var */_defendName: GTextFiled;

        /* internal */ /* var */_defendMember: GTextFiled;

        /* internal */ /* var */_defendMemberList: PetIslandFightMemberListPanel;

        /* internal */ /* var */_defendLifeBar: ProgressBase;

        /* internal */ /* var */_bg: GImageBitmap;

        /* internal */ /* var */_hideBattleBtn: GLoadedButton;

        /* internal */ /* var */_fightPic: GLoadedButton;

        /* internal */ /* var */_listSp: Object /* flash.display.Sprite */;

        /* internal */ /* var */_data: SRobIslandFightingDetail;
    }
